﻿function checkalter()
{
	var f = form("AlterForm");
	if (f.Email.value == '')
	{
		alert("Email 地址不能留空！");
		f.Email.focus();
		return false;
	}
	if (f.Email.value.search(/^[^\s@:"'<>,&]{2,}@[^\[\.]+\.[^\[]{2,}$/gi) < 0)
	{
		alert('请正确填写你的邮件地址！');
		f.Email.focus();
		return false;
	}
	if (f.Email.value.length > 45)
	{
		alert('请正确填写你的邮件地址！');
		f.Email.focus();
		return false;
	}
	if (f.Postcode.value != '')
	{
		if (f.Postcode.value.length != 6 || isNaN(f.Postcode.value))
		{
			alert('请正确填写邮政编码！');
			f.Postcode.focus();
			return false;
		}
	}
	if (f.QQ.value != '')
	{
		if (f.QQ.value.length < 5 || f.QQ.value.length > 15 || isNaN(f.QQ.value))
		{
			alert('请正确填写QQ号码！');
			f.QQ.focus();
			return false;
		}
	}
	if (f.Msn.value != '')
	{
		if (f.Msn.value.search(/^[^\s@:"'<>,&]{2,}@[^\[\.]+\.[^\[]{2,}$/gi) < 0)
		{
			alert('请正确填写你的 MSN！');
			f.Msn.focus();
			return false;
		}
	}
	if (f.Yahoo.value != '')
	{
		if (f.Yahoo.value.search(/^[^\s@:"'<>,&]{2,}@[^\[\.]+\.[^\[]{2,}$/gi) < 0)
		{
			alert('请正确填写你的 yahoo 帐号！');
			f.Yahoo.focus();
			return false;
		}
	}
	
	if (f.Alipay.value != '')
	{
		if (f.Alipay.value.search(/^[^\s@:"'<>,&]{2,}@[^\[\.]+\.[^\[]{2,}$/gi) < 0)
		{
			alert('请正确填写你的支付宝帐号！');
			f.Alipay.focus();
			return false;
		}
	} 
	
	if (f.Year.value != '')
	{
		if (isNaN(f.Year.value) || parseInt(f.Year.value) > 3000 || parseInt(f.Year.value) < 1900)
		{
			alert('请正确填写出生年份!');
			f.Year.focus();
			return false;
		}
	}
	
	if (f.Cellphone.value != '')
	{
		if (isNaN(f.Cellphone.value) || f.Cellphone.value.length != 11)
		{
			alert('请正确填手机号码!');
			f.Cellphone.focus();
			return false;
		}
	}
	if (f.Signature.value.length > SignatureSize)
	{
		alert('个性签名过长，当前只允许 ' + SignatureSize + " 个字符！");
		f.Signature.focus();
		return false;
	}

	signaturewin.document.designMode = 'on';
	signaturewin.document.write('');
	signaturewin.document.close();
	signaturewin.document.body.innerHTML = ubb2html(f.Signature.value);
	f.Signature.value = html2ubb(signaturewin.document.body.innerHTML);
	
	if (f.password.value == '')
	{
		alert('为了安全起见，请先输入您的论坛登录密码！');
		f.password.focus();
		return false;
	}
	if (f.verification)
	{
		if (f.verification.value == '')
		{
			alert('请输入验证码');
			f.verification.focus();
			return false;
		}
	}	
}

function showDialog(w, h, html)
{
	var div = $('inputdialog');
	if (div == null)
	{
		div = document.createElement("div");
		div.id = 'inputdialog';
		div.className = 'grid';
		div.style.position = 'absolute';
		div.style.padding = '3px';
		document.body.appendChild(div);
	}
	div.style.top = '200px';
	div.style.left = '200px';
	div.style.width = w + 'px';
	div.style.height = h + 'px';
	div.innerHTML = html;
}